{include file="public/header" /}
<script charset="utf-8" src="/public/static/admin/myeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="/public/static/admin/myeditor/lang/zh_CN.js"></script>
<div class="layui-layout layui-layout-admin">
	{include file="public/left" /}

	<div class="layui-body">
		<div class="layui-tab layui-tab-brief" lay-filter="tab">
			<ul class="layui-tab-title">
				<li><a href="{:url('/Infos',"typeid=".input('typeid')."")}">{:get_forms_zd(input('typeid',0),'title')}管理</a></li>
				<li class="layui-this"><a href="{:url('Forms/Add')}">字段添加</a></li>
			</ul>
			<div class="layui-tab-content">
				<div class="layui-tab-item layui-show">
					<form action="" method="post" class="layui-form" onSubmit="return check_myforms(this);">
						<input type="hidden" name="typeid" value="{:input('typeid')}">
						<input type="hidden" name="id" value="{:input('id')}">
						{volist name=":get_list_myfields_list(input('typeid'))" id="vs"}

							{if condition="$vs['Field'] eq 11111"}
								{for start="1" end="config('BANNER_NUM')+1"}
								<?php
									$i++;
									$zd="img$i";?>
								<div class="layui-form-item">
									<label class="layui-form-label">配置文件</label>
									<div class="layui-input-inline">
										<input type="text" name="img{$i}" id="img{$i}" value="{$v[$zd]}" placeholder="请上传配置图片"  class="layui-input">
									</div>
									<button type="button" id="img{$i}_btn" class="layui-btn" data-des="ico">
										<i class="layui-icon">&#xe67c;</i>上传图片
									</button>
									{:get_img_show($v[$zd])}
									<font color="red">图片大小:<!-- {:get_cfg_var("post_max_size")} -->内,图片尺寸：px</font>
								</div>
							{/for}
							{else/}
								<div class="layui-form-item">
									<label class="layui-form-label">{$vs.title}</label>
									<div class="layui-input-inline">
										<input type="text"  name="{$vs.Field}" placeholder="" class="layui-input" value="{:$v[$vs['Field']]}">
									</div>
								</div>
							{/if}
							
						{/volist}

						<div class="layui-form-item">
							<div class="layui-input-block">
								<button class="layui-btn" lay-submit >立即提交</button>
								<button type="reset" class="layui-btn layui-btn-primary">重置</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>

	{include file="public/footer" /}

</div>

<script>
    function checkspaces(checkstr) {
        var str = '';
        for(i = 0; i < checkstr.length; i++)
        {
            str = str + ' ';
        }
        return (str == checkstr);
    }

    function check_myforms(formlist){
    {volist name=":get_js_myfields_list(input('typeid'))" id="vs"}
		{$vs.js}
    {/volist}
    }
</script>
<script type="text/javascript">
	KindEditor.ready(function(K) {
		var editor1 = K.create('.editor_id', {
            filterMode: false,//是否开启过滤模式
            cssPath : '/public/static/admin/myeditor/plugins/code/prettify.css',
            uploadJson : '/public/static/admin/myeditor/php/upload_json.php',
            fileManagerJson : '/public/static/admin/myeditor/php/file_manager_json.php',
            allowFileManager : true,
            afterBlur : function() {
                this.sync();
                K.ctrl(document, 13, function() {
                    K('form[name=formlist]')[0].submit();
                });
                K.ctrl(this.edit.doc, 13, function() {
                    K('form[name=formlist]')[0].submit();
                });
            }
        });

        var editor = K.editor({
            allowFileManager : true
        });

	{for start="1" end="2"}
            K('#img{$i}_btn').click(function() {
                editor.loadPlugin('image', function() {
                    editor.plugin.imageDialog({
                        imageUrl : K('#img{$i}').val(),
                        clickFn : function(url, title, width, height, border, align) {
                            K('#img{$i}').val(url);
                            editor.hideDialog();
                        }
                    });
                });
            });
        });
    {/for}
</script>
</body>
</html>
